﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLayer.Model.Repositories.Abstract;
using System.Globalization;
using BusinessLayer;
using DataAccess.Repositories;

public partial class Events : System.Web.UI.Page
{
    IEventRepository _eventsRepository = new EventRepository();
    protected CultureInfo provider = CultureInfo.CurrentCulture;
    
    protected void Page_Load(object sender, EventArgs e)
    {        
        BindDataList();
    }

    private void BindDataList()
    {
        dlEvents.DataSource = _eventsRepository.FetchAll().OrderBy(e => e.Date);
        dlEvents.DataBind();
    }

    public static string GetMonthName(int month)
    {

        string[] months = new string[12] { "Enero", "Febrero", "Marzo",
                                                  "Abril", "Mayo", "Junio",
                                                  "Julio", "Agosto", "Septiembre",
                                                  "Octubre", "Noviembre", "Diciembre"
                                          };

        if (month >= 1 && month <= 12)
            return months[month - 1];
        else
            return null;

    }

    public static string GetSpanishDay(string day)
    {
        string[] engDays = new string[7] { "Monday", "Tuesday", "Wednesday",
                                          "Thursday", "Friday", "Saturday", "Sunday"};
        string[] spaDays = new string[7] {"Lunes","Martes","Miércoles", 
                                            "Jueves", "Viernes", "Sábado", "Domingo"};

        for (int x = 0; x < 7; x++)
            if (engDays[x].Equals(day))
                return spaDays[x];

        return day;


    }


}
